package dir;

import java.io.File;
import java.nio.charset.StandardCharsets;

/**
 * @author wzby
 * @Date: 2022/8/1 15:27
 */
public class Dir4 {
    public static void main(String[] args) {
        String dir = "E:\\uexdir\\user";
        File f = new File(dir);
        File[] fs = f.listFiles();
        // : 冒号在for循环中用来遍历数组（集合）中的元素
        for (File t : fs) {
            //System.out.println(t.isFile());
            //System.out.println(t.isDirectory());
            System.out.println(t.getAbsoluteFile());
            String sf = String.format("%s:%s", t.isDirectory() ? "目录" : "文件", t.getAbsoluteFile());
            System.out.println(sf);
            //.getAbsoluteFile() 方法返回此抽象路径名的绝对形式。
        }
        System.out.println("===".repeat(25));
        String[] fl = f.list();
        for (String t : fl){
            File tf = new File("E:\\uexdir\\user",t);
            //System.out.println(tf.isFile());
            //System.out.println(tf.isDirectory());
            System.out.println(tf.getAbsoluteFile());
            System.out.println(t);
        }

    }
}
